const koa = require('koa')
const app = new koa()
const session = require('koa-session')

const router = require('./router')



const passport = require('./passport')
app.use(passport.initialize())
app.use(passport.session())

app.keys = ['123456']
app.use(session({
  maxAge:86400000,
  secure: false,
  cookie: {secure: false, maxAge: 86400000}
}, app))

router.all('404', ctx => {
  ctx.status = 404
  ctx.body = '404'
})
app.use(router.routes())
app.use(router.allowedMethods())

app.listen(3000, () => {
  console.log('server is running at port 3000')
})